<?php

class ctrl_firadio_php_admin_sys_menuitem extends ctrl_firadio_php_admin_common {

    public function action_list() {
        // 默认的排序
        $this->table->defaorder = 'menuitem.id ASC';
        // 要读取的字段
        $this->table->field = 'menuitem.id,menuitem.name,menuitem.title,menuclass.name classname,menuclass.parentdir,menuitem.enable,menuitem.visible,CONCAT(menuitem.enable,menuitem.visible) status';
        // 获取查询列表
        $this->tablelist = $this->table->getList();
        return($this->getdata());
    }

    public function action_add() {
        // 判断是否提交请求
        if ($_POST) {
            // 给菜单添加项
            $this->ret = $this->menu->additem($_POST);
        }
        return($this->getdata());
    }

    public function action_edit() {
        // 提交菜单项的编辑
        $this->ret = $this->menu->setItemInfo($_GET['id'], $_POST);
        return($this->getdata());
    }

    public function action_del() {
        return($this->getdata());
    }

    public function action_info() {
        // 提取菜单信息
        $this->tables['menuinfo'] = $this->menu->getItemById($_GET['id']);
        // 获取菜单分类信息
        $this->tables['menuclassinfo'] = $this->menu->getClassInfo($this->tables['menuinfo']['menuclassid']);
        return($this->getdata());
    }

}